package com.kmxd.ams.core.oss;

import com.kmxd.ams.core.oss.properties.OssProperties;
import com.kmxd.ams.core.oss.template.OssTemplate;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * oss 自动配置类
 *
 * @author ZuoLG
 */
@Configuration(proxyBeanMethods = false)
@EnableConfigurationProperties({OssProperties.class})
@ConditionalOnProperty(prefix = OssProperties.PREFIX, name = "enable", havingValue = "true")
public class OssAutoConfiguration {

  /**
   * oss操作模板
   *
   * @param properties oss配置
   * @return OssTemplate
   */
  @Bean
  @ConditionalOnMissingBean(OssTemplate.class)
  public OssTemplate ossTemplate(OssProperties properties) {
    return new OssTemplate(properties);
  }
}
